home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / OS Utilities / CPUGestalt / CPUGestalt.c next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.3 KB  |  67 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        CPUGestalt.c
  3.  
  4.     Contains:    This sample code illustrates the way to determine the 
  5.                 processor type of the Macintosh you're running on    
  6.     
  7.  
  8.     Written by:     
  9.  
  10.     Copyright:    Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.                 You may incorporate this Apple sample source code into your program(s) without
  13.                 restriction. This Apple sample source code has been provided "AS IS" and the
  14.                 responsibility for its operation is yours. You are not permitted to redistribute
  15.                 this Apple sample source code as "Apple sample source code" after having made
  16.                 changes. If you're going to re-distribute the source, we require that you make
  17.                 it clear in the source that the code was descended from Apple sample source
  18.                 code, but that you've made changes.
  19.  
  20.     Change History (most recent first):
  21.                 7/23/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1 and
  22.                                             Added PowerPC 750 processor
  23.                 
  24.  
  25. */
  26.  
  27. #include <Gestalt.h>
  28. #include <stdio.h>
  29.  
  30. void main()
  31. {
  32.     OSErr    err;
  33.     long    getCPUtype;
  34.         
  35.     // check to see if we're on a Power Macintosh
  36.     err = Gestalt (gestaltNativeCPUtype, &getCPUtype);
  37.     
  38.     if (0x100 & getCPUtype) {
  39.         // we are on a Power Macintosh
  40.         if (getCPUtype == gestaltCPU601)
  41.             printf( "\nThis is a Power Macintosh with a 601 processor." );
  42.         else if (getCPUtype == gestaltCPU603)
  43.             printf( "\nThis is a Power Macintosh with a 603 processor." );
  44.         else if (getCPUtype == gestaltCPU604)
  45.             printf( "\nThis is a Power Macintosh with a 604 processor." );
  46.         else if (getCPUtype==gestaltCPU750)
  47.             printf( "\nThis is a Power Macintosh with a 750(G3) processor." );
  48.         else
  49.             printf( "\nThis is a Power Macintosh with a processor that I am unaware of." );
  50.     } else {
  51.         // we are on a 68K Macintosh
  52.         err = Gestalt ( gestaltProcessorType, &getCPUtype );
  53.         if (getCPUtype == gestalt68040)
  54.             printf( "\nThis is a 68K Macintosh with a 68040 processor." );
  55.         else if (getCPUtype == gestalt68030)
  56.             printf( "\nThis is a 68K Macintosh with a 68030 processor." );
  57.         else if (getCPUtype == gestalt68020)
  58.             printf( "\nThis is a 68K Macintosh with a 68020 processor." );
  59.         else if (getCPUtype == gestalt68010)
  60.             printf( "\nThis is a 68K Macintosh with a 68010 processor." );
  61.         else if (getCPUtype == gestalt68000)
  62.             printf( "\nThis is a 68K Macintosh with a 68000 processor." );
  63.         else
  64.             printf( "\nThis is a 68K Macintosh with a processor that I am unaware of." );
  65.     }
  66. }
  67.